package com.jiamao.goplay.ui.discover.vm;

import android.os.Bundle;

import com.jiamao.goplay.bean.HotCityItem;
import com.jiamao.goplay.bean.NearbyItem;
import com.jiamao.goplay.ui.discover.AddrDetailFragment;
import com.jiamao.goplay.ui.discover.CityFragment;
import com.jiamao.goplay.ui.discover.CityGoToFragment;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;
import me.goldze.mvvmhabit.base.BaseViewModel;
import me.goldze.mvvmhabit.base.MultiItemViewModel;
import me.goldze.mvvmhabit.binding.command.BindingAction;
import me.goldze.mvvmhabit.binding.command.BindingCommand;

public class NeayByHotCityItemVM extends MultiItemViewModel {


    public ObservableField<String> imgUrl = new ObservableField<>("");
    public ObservableField<String> name = new ObservableField<>("");
    public ObservableField<String> addr = new ObservableField<>("");


    private HotCityItem data;
    public NeayByHotCityItemVM(@NonNull BaseViewModel viewModel, HotCityItem item) {
        super(viewModel);
        if (item == null) {
            return;
        }
        this.data = item;

        imgUrl.set(item.getCityCover());
        name.set(item.getCityName());
        addr.set(item.getCityNum()+"个地点，"+item.getInterestUserNum()+"人想去");
    }


    //条目的点击事件
    public BindingCommand itemClick = new BindingCommand(new BindingAction() {
        @Override
        public void call() {

            if (data==null){
              //  viewModel.startContainerActivity(AddrDetailFragment.class.getCanonicalName());
                return;
            }
            Bundle bundle = new Bundle();
            bundle.putString("name",data.getCityName());
            viewModel.startContainerActivity(CityGoToFragment.class.getCanonicalName(),bundle);


          //  viewModel.startContainerActivity(AddrDetailFragment.class.getCanonicalName());
         //   ToastUtils.showShort("我是头布局");
        }
    });

    //条目的点击事件
    public BindingCommand addClick = new BindingCommand(new BindingAction() {
        @Override
        public void call() {



            viewModel.startContainerActivity(CityFragment.class.getCanonicalName());


            //  viewModel.startContainerActivity(AddrDetailFragment.class.getCanonicalName());
            //   ToastUtils.showShort("我是头布局");
        }
    });
}
